
#pragma once

#include <map>
#include <string>
#include <iostream>
#include <sstream>

#include "core\types.h"
#include "core\exception.h"

class CObjectManager
{
public:
#if _USE_BOOST_
    typedef boost::ptr_unordered_map<ObjectID_t, CObject> ObjectsMap_t;
#else
    typedef map<ObjectID_t, CObject*> ObjectsMap_t;
#endif

    struct BadIDException : public CException
    {
        BadIDException(ObjectID_t id) : m_ID(id), CException() 
        {
            stringstream s;
            s << "bad object id: " << m_ID;
            m_sDescription = s.str();
        }
        ObjectID_t m_ID;
    };

    CObjectManager();
    virtual ~CObjectManager() {}

    ObjectID_t Add(CObject*);
    void Remove(ObjectID_t);
    CObject* Get(ObjectID_t);

#ifdef _DEBUG
    void Dump() const;
    void ValidateID(ObjectID_t);
#endif

private:
    ObjectsMap_t _Objects;
};
